function axios(config){
	const {url,method="get",cancelToken} = config;
	return new Promise((resolve,reject)=>{
		const request = new XMLHttpRequest();
		request.responseType = "json";
		request.open(method,url);
		request.send();
		request.onload = function(){
			resolve({
				config,
				data:request.response,
				headers:request.getAllResponseHeaders(),
				request,
				status:request.status,
				statusText:request.statusText
			});
		}
		request.onabort = function(){
			reject({
				error:"取消了请求"
			})
		}
		if(cancelToken){
			cancelToken.cancel.then(()=>{
				request.abort()// 取消
			})
		}
	})
}
axios.CancelToken = function(cb){
	this.cancel = new Promise(function(resolve,reject){
		cb(resolve);
	})
}
axios.get = function(url,config={}){
	return this({
		...config,
		url
	})
}